﻿using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

namespace InfoPathHelpers.Cryptography
{
    public static class SymmetricAlgorithmHelper
    {
        public static RijndaelManaged CreateRijndaelSession(string key, byte[] salt)
        {
            var SymmetricAlgorithm = new RijndaelManaged();
            var DerivedByteArray = new Rfc2898DeriveBytes(key, salt);
            SymmetricAlgorithm.Key = DerivedByteArray.GetBytes(SymmetricAlgorithm.KeySize >> 3);
            SymmetricAlgorithm.IV = DerivedByteArray.GetBytes(SymmetricAlgorithm.BlockSize >> 3);
            return SymmetricAlgorithm;
        }
    }
}
